/// **************************************************************************************************
/// "Copyright (c) 2007 Sai Panyam, Inc.  All rights reserved."
/// **************************************************************************************************
/// Component Name   :	OperationFactory, Member of System72.NTextile 
/// Description      :	OperationFactory description
/// Author           :	Sai Panyam
/// Creation Date    :	November 09 2007
/// Modified Date    :              
/// Modified By      :
/// **************************************************************************************************
using System;

namespace System72.NTextile
{
    /// <summary>
    /// 
    /// </summary>
    internal class OperationFactory
    {
        #region Private Variables

        private readonly PhraseModifierType m_phraseModifierType;
        private readonly BlockModifierType m_blockModifierType;
        private readonly ListModifierType m_listModifierType;

        #endregion

        #region Constructor
        /// <summary>
        /// 
        /// </summary>
        /// <param name="phraseModifierType"></param>
        public OperationFactory(PhraseModifierType phraseModifierType)
        {
            m_phraseModifierType = phraseModifierType;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="blockModifierType"></param>
        public OperationFactory(BlockModifierType blockModifierType)
        {
            m_blockModifierType = blockModifierType;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="listModifierType"></param>
        public OperationFactory(ListModifierType listModifierType)
        {
            m_listModifierType = listModifierType;
        }

        #endregion

        #region Public Methods
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public Operation GetPhraseOperation()
        {
            Operation operation = new Operation();
            switch (m_phraseModifierType)
            {
                case PhraseModifierType.Citation:
                    operation.Tag = "cite";
                    operation.Operator = "??";
                    operation.RegExOperator = @"\?{2}";
                    operation.ModifierType = ModifierType.Citation;
                    break;
                case PhraseModifierType.Bold:
                    operation.Tag = "b";
                    operation.Operator = "**";
                    operation.RegExOperator = @"\*{2}";
                    operation.ModifierType = ModifierType.Bold;
                    break;
                case PhraseModifierType.DeletedText:
                    operation.Tag = "del";
                    operation.Operator = "-";
                    operation.RegExOperator = "-";
                    operation.ModifierType = ModifierType.DeletedText;
                    break;
                case PhraseModifierType.Emphasis:
                    operation.Tag = "em";
                    operation.Operator = "_";
                    operation.RegExOperator = "_";
                    operation.ModifierType = ModifierType.Emphasis;
                    break;
                case PhraseModifierType.Italics:
                    operation.Tag = "i";
                    operation.Operator = "__";
                    operation.RegExOperator = "__";
                    operation.ModifierType = ModifierType.Italics;
                    break;
                case PhraseModifierType.InsertedText:
                    operation.Tag = "ins";
                    operation.Operator = "+";
                    operation.RegExOperator = @"\+";
                    operation.ModifierType = ModifierType.InsertedText;
                    break;
                case PhraseModifierType.Span:
                    operation.Tag = "span";
                    operation.Operator = "%";
                    operation.RegExOperator = "%";
                    operation.ModifierType = ModifierType.Span;
                    break;
                case PhraseModifierType.Strong:
                    operation.Tag = "strong";
                    operation.Operator = "*";
                    operation.RegExOperator = @"\*";
                    operation.ModifierType = ModifierType.Strong;
                    break;
                case PhraseModifierType.SubScript:
                    operation.Tag = "sub";
                    operation.Operator = "~";
                    operation.RegExOperator = "~";
                    operation.ModifierType = ModifierType.SubScript;
                    break;
                case PhraseModifierType.SuperScript:
                    operation.Tag = "sup";
                    operation.Operator = "^";
                    operation.RegExOperator = @"\^";
                    operation.ModifierType = ModifierType.SuperScript;
                    break;
                default:
                    throw new NotSupportedException("PhraseModifierType :" + m_phraseModifierType + " not yet supported");
            }

            return operation;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public Operation GetBlockOperation()
        {
            Operation operation = new Operation();
            switch (m_blockModifierType)
            {
                case BlockModifierType.Blockcode:
                    operation.Tag = "code";
                    operation.Operator = "bc.";
                    operation.RegExOperator = "bc";
                    operation.ModifierType = ModifierType.Blockcode;
                    break;
                case BlockModifierType.Blockquote:
                    operation.Tag = "blockquote";
                    operation.Operator = "bq.";
                    operation.RegExOperator = "bq";
                    operation.ModifierType = ModifierType.Blockquote;
                    break;
                case BlockModifierType.Header1:
                    operation.Tag = "h1";
                    operation.Operator = "h1.";
                    operation.RegExOperator = "h1";
                    operation.ModifierType = ModifierType.Header1;
                    break;
                case BlockModifierType.Header2:
                    operation.Tag = "h2";
                    operation.Operator = "h2.";
                    operation.RegExOperator = "h2";
                    operation.ModifierType = ModifierType.Header2;
                    break;
                case BlockModifierType.Header3:
                    operation.Tag = "h3";
                    operation.Operator = "h3.";
                    operation.RegExOperator = "h3";
                    operation.ModifierType = ModifierType.Header3;
                    break;
                case BlockModifierType.Header4:
                    operation.Tag = "h4";
                    operation.Operator = "h4.";
                    operation.RegExOperator = "h4";
                    operation.ModifierType = ModifierType.Header4;
                    break;
                case BlockModifierType.Header5:
                    operation.Tag = "h5";
                    operation.Operator = "h5.";
                    operation.RegExOperator = "h5";
                    operation.ModifierType = ModifierType.Header5;
                    break;
                case BlockModifierType.Header6:
                    operation.Tag = "h6";
                    operation.Operator = "h6.";
                    operation.RegExOperator = "h6";
                    operation.ModifierType = ModifierType.Header6;
                    break;
                case BlockModifierType.Paragraph:
                    operation.Tag = "p";
                    operation.Operator = "p.";
                    operation.RegExOperator = "p";
                    operation.ModifierType = ModifierType.Paragraph;
                    break;
                case BlockModifierType.Preformat:
                    operation.Tag = "pre";
                    operation.Operator = "pre.";
                    operation.RegExOperator = "pre";
                    operation.ModifierType = ModifierType.Preformat;
                    break;
                case BlockModifierType.NoTextile:
                    operation.Tag = "p";
                    operation.Operator = "notextile.";
                    operation.RegExOperator = "notextile";
                    operation.ModifierType = ModifierType.NoTextile;
                    break;
                default:
                    throw new NotSupportedException("BlockModifierType :" + m_blockModifierType + " not yet supported");
            }

            return operation;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public Operation GetListOperation()
        {
            Operation operation = new Operation();
            switch (m_listModifierType)
            {
                case ListModifierType.NumericList:
                    operation.Tag = "li";
                    operation.Operator = "#";
                    operation.RegExOperator = @"\#";
                    operation.ModifierType = ModifierType.NumericList;
                    break;
                case ListModifierType.BulletedList:
                    operation.Tag = "li";
                    operation.Operator = "*";
                    operation.RegExOperator = @"\*";
                    operation.ModifierType = ModifierType.BulletedList;
                    break;
                default:
                    throw new NotSupportedException("ListModifierType :" + m_listModifierType + " not yet supported");
            }
            return operation;
        }

        #endregion
    }
}
